import http from '@/utils/api/index'

export const getBind = async (type, bind_id) => {
  switch (type) {
    case 'note':
      type = 1
      break
    case 'article':
      type = 0
      break
    default:
      break
  }
  let res = await http.get('/system/img/list', {
    params: {
      moduleFlag: type,
      itemId: bind_id
    }
  })
  return res.data.rows
}

export const setBind = async (type, bind_id, img_url) => {
  let res = await http.post('/system/img', {
    imgUrl: img_url,
    itemId: bind_id,
    moduleFlag: type
  })
  return res.data
}

export const unBind = async (bind_id) => {
  let res = await http.delete(`/system/img/${bind_id}`)
  return res.data
}
